using AppToolKit.Business;
using System;
namespace AppToolKit.Core.Context.Spring.AutoConstruction.Builder
{
	public class CustomImplBusinessSupport
	{
		public bool IsSupport(Type type)
		{
			return TypeHelper.IsInheritGenericInterface(type, typeof(IBusiness<>));
		}
		public Type GetEntityType(Type target)
		{
			Type typeFromHandle = typeof(IBusiness<>);
			Type[] interfaces = target.GetInterfaces();
			for (int i = 0; i < interfaces.Length; i++)
			{
				Type type = interfaces[i];
				if (type.IsGenericType && type.GetGenericTypeDefinition().Equals(typeFromHandle))
				{
					return type.GetGenericArguments()[0];
				}
			}
			throw new AutoConstructionException(string.Format("CustomImplBusinessServerbuilder找不到entity类型{0}", target));
		}
	}
}
